<!--
Copyright Louis Dionne 2013-2016
Distributed under the Boost Software License, Version 1.0.
(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
-->
<!-- boost-no-inspect -->
<!-- HTML header for doxygen 1.8.9.1-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.11"/>
<title>Boost.Hana: boost::hana::type&lt; T &gt; Struct Template Reference</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
  $(window).load(resizeHeight);
</script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
  $(document).ready(function() { init_search(); });
</script>
<script type="text/x-mathjax-config">
  MathJax.Hub.Config({
    extensions: ["tex2jax.js"],
    jax: ["input/TeX","output/HTML-CSS"],
});
// Copyright Louis Dionne 2013-2016
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
MathJax.Hub.Config({
    "HTML-CSS": {
        linebreaks: {
            automatic: true,
            width: "75% container"
        }
    }
});
</script><script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<!-- Additional javascript for drawing charts. -->
<script type="text/javascript" src="highcharts.js"></script>
<script type="text/javascript" src="highcharts-data.js"></script>
<script type="text/javascript" src="highcharts-exporting.js"></script>
<script type="text/javascript" src="chart.js"></script>
<script type="text/javascript" src="hana.js"></script>
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectlogo"><img alt="Logo" src="Boost.png"/></td>
  <td style="padding-left: 0.5em;">
   <div id="projectname">Boost.Hana
   &#160;<span id="projectnumber">1.0.2</span>
   </div>
   <div id="projectbrief">Your standard library for metaprogramming</div>
  </td>
   <td>        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.png"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)"
               onblur="searchBox.OnSearchFieldFocus(false)"
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
          </span>
        </div>
</td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.11 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;"
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
$(document).ready(function(){initNavTree('structboost_1_1hana_1_1type.html','');});
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0"
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="header">
  <div class="summary">
<a href="#related">Synopsis of associated functions</a> &#124;
<a href="#friends">Friends</a> &#124;
<a href="#pub-methods">Public Member Functions</a> &#124;
<a href="structboost_1_1hana_1_1type-members.html">List of all members</a>  </div>
  <div class="headertitle">
<div class="title">boost::hana::type&lt; T &gt; Struct Template Reference<div class="ingroups"><a class="el" href="group__group-datatypes.html">Data types</a></div></div>  </div>
</div><!--header-->
<div class="contents">
<a name="details" id="details"></a><h2 class="groupheader">Description</h2>
<div class="textblock"><h3>template&lt;typename T&gt;<br />
struct boost::hana::type&lt; T &gt;</h3>

<p>C++ type in value-level representation. </p>
<p>A <code>type</code> is a special kind of object representing a C++ type like <code>int</code>, <code>void</code>, <code>std::vector&lt;float&gt;</code> or anything else you can imagine.</p>
<p>This page explains how <code>type</code>s work at a low level. To gain intuition about type-level metaprogramming in Hana, you should read the <a class="el" href="index.html#tutorial-type">tutorial section</a> on type-level computations.</p>
<dl class="section note"><dt>Note</dt><dd>For subtle reasons having to do with ADL, the actual representation of <code><a class="el" href="structboost_1_1hana_1_1type.html" title="C++ type in value-level representation. ">hana::type</a></code> is implementation-defined. In particular, <code><a class="el" href="structboost_1_1hana_1_1type.html" title="C++ type in value-level representation. ">hana::type</a></code> may be a dependent type, so one should not attempt to do pattern matching on it. However, one can assume that <code><a class="el" href="structboost_1_1hana_1_1type.html" title="C++ type in value-level representation. ">hana::type</a></code> <em>inherits</em> from <code><a class="el" href="structboost_1_1hana_1_1basic__type.html" title="Base class of hana::type; used for pattern-matching. ">hana::basic_type</a></code>, which can be useful when declaring overloaded functions: <div class="fragment"><div class="line"><span class="keyword">template</span> &lt;<span class="keyword">typename</span> T&gt;</div><div class="line"><span class="keywordtype">void</span> f(hana::basic_type&lt;T&gt;) {</div><div class="line">    <span class="comment">// do something with T</span></div><div class="line">}</div></div><!-- fragment --></dd></dl>
<p><a class="anchor" id="type_lvalues_and_rvalues"></a></p><h2>Lvalues and rvalues </h2>
<p>When storing <code>type</code>s in heterogeneous containers, some algorithms will return references to those objects. Since we are primarily interested in accessing their nested <code>::type</code>, receiving a reference is undesirable; we would end up trying to fetch the nested <code>::type</code> inside a reference type, which is a compilation error: </p><div class="fragment"><div class="line"><span class="keyword">auto</span> ts = make_tuple(type_c&lt;int&gt;, type_c&lt;char&gt;);</div><div class="line"><span class="keyword">using</span> T = decltype(ts[0_c])::type; <span class="comment">// error: &#39;ts[0_c]&#39; is a reference!</span></div></div><!-- fragment --><p>For this reason, <code>type</code>s provide an overload of the unary <code>+</code> operator that can be used to turn a lvalue into a rvalue. So when using a result which might be a reference to a <code>type</code> object, one can use <code>+</code> to make sure a rvalue is obtained before fetching its nested <code>::type</code>: </p><div class="fragment"><div class="line"><span class="keyword">auto</span> ts = make_tuple(type_c&lt;int&gt;, type_c&lt;char&gt;);</div><div class="line"><span class="keyword">using</span> T = decltype(+ts[0_c])::type; <span class="comment">// ok: &#39;+ts[0_c]&#39; is an rvalue</span></div></div><!-- fragment --><h2>Modeled concepts </h2>
<ol type="1">
<li><code>Comparable</code><br />
Two types are equal if and only if they represent the same C++ type. Hence, equality is equivalent to the <code>std::is_same</code> type trait. <div class="fragment"><div class="line"><span class="comment">// Copyright Louis Dionne 2013-2016</span></div><div class="line"><span class="comment">// Distributed under the Boost Software License, Version 1.0.</span></div><div class="line"><span class="comment">// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)</span></div><div class="line"></div><div class="line"><span class="preprocessor">#include &lt;<a class="code" href="assert_8hpp.html">boost/hana/assert.hpp</a>&gt;</span></div><div class="line"><span class="preprocessor">#include &lt;<a class="code" href="equal_8hpp.html">boost/hana/equal.hpp</a>&gt;</span></div><div class="line"><span class="preprocessor">#include &lt;<a class="code" href="not__equal_8hpp.html">boost/hana/not_equal.hpp</a>&gt;</span></div><div class="line"><span class="preprocessor">#include &lt;<a class="code" href="type_8hpp.html">boost/hana/type.hpp</a>&gt;</span></div><div class="line"><span class="keyword">namespace </span>hana = <a class="code" href="namespaceboost_1_1hana.html">boost::hana</a>;</div><div class="line"></div><div class="line"></div><div class="line"><span class="keyword">struct </span>T;</div><div class="line"><span class="keyword">struct </span>U;</div><div class="line"><a class="code" href="group__group-assertions.html#ga4bf9e0c46c44e21fbe5c5fbb3ace8356">BOOST_HANA_CONSTANT_CHECK</a>(hana::type_c&lt;T&gt; == hana::type_c&lt;T&gt;);</div><div class="line"><a class="code" href="group__group-assertions.html#ga4bf9e0c46c44e21fbe5c5fbb3ace8356">BOOST_HANA_CONSTANT_CHECK</a>(hana::type_c&lt;T&gt; != hana::type_c&lt;U&gt;);</div><div class="line"></div><div class="line"><span class="keywordtype">int</span> main() { }</div></div><!-- fragment --></li>
<li><code>Hashable</code><br />
The hash of a type is just that type itself. In other words, <code>hash</code> is the identity function on <code><a class="el" href="structboost_1_1hana_1_1type.html" title="C++ type in value-level representation. ">hana::type</a></code>s. <div class="fragment"><div class="line"><span class="comment">// Copyright Louis Dionne 2013-2016</span></div><div class="line"><span class="comment">// Distributed under the Boost Software License, Version 1.0.</span></div><div class="line"><span class="comment">// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)</span></div><div class="line"></div><div class="line"><span class="preprocessor">#include &lt;<a class="code" href="assert_8hpp.html">boost/hana/assert.hpp</a>&gt;</span></div><div class="line"><span class="preprocessor">#include &lt;<a class="code" href="equal_8hpp.html">boost/hana/equal.hpp</a>&gt;</span></div><div class="line"><span class="preprocessor">#include &lt;<a class="code" href="hash_8hpp.html">boost/hana/hash.hpp</a>&gt;</span></div><div class="line"><span class="preprocessor">#include &lt;<a class="code" href="type_8hpp.html">boost/hana/type.hpp</a>&gt;</span></div><div class="line"><span class="keyword">namespace </span>hana = <a class="code" href="namespaceboost_1_1hana.html">boost::hana</a>;</div><div class="line"></div><div class="line"></div><div class="line"><span class="comment">// `hana::hash` is the identity on `hana::type`s.</span></div><div class="line"><a class="code" href="group__group-assertions.html#ga4bf9e0c46c44e21fbe5c5fbb3ace8356">BOOST_HANA_CONSTANT_CHECK</a>(<a class="code" href="group__group-Comparable.html#gacaf1ebea6b3ab96ac9dcb82f0e64e547">hana::equal</a>(</div><div class="line">    <a class="code" href="group__group-Hashable.html#ga6e906f44f47b210615491385e5c8a7b5">hana::hash</a>(hana::type_c&lt;int&gt;),</div><div class="line">    hana::type_c&lt;int&gt;</div><div class="line">));</div><div class="line"></div><div class="line"><a class="code" href="group__group-assertions.html#ga4bf9e0c46c44e21fbe5c5fbb3ace8356">BOOST_HANA_CONSTANT_CHECK</a>(<a class="code" href="group__group-Comparable.html#gacaf1ebea6b3ab96ac9dcb82f0e64e547">hana::equal</a>(</div><div class="line">    <a class="code" href="group__group-Hashable.html#ga6e906f44f47b210615491385e5c8a7b5">hana::hash</a>(hana::type_c&lt;void&gt;),</div><div class="line">    hana::type_c&lt;void&gt;</div><div class="line">));</div><div class="line"></div><div class="line"><span class="keywordtype">int</span> main() { }</div></div><!-- fragment --> </li>
</ol>
</div><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="related"></a>
Synopsis of associated functions</h2></td></tr>
<tr class="memitem:ae35139e732c4b75e91061513cf445628"><td class="memTemplParams" colspan="2">template&lt;typename T &gt; </td></tr>
<tr class="memitem:ae35139e732c4b75e91061513cf445628"><td class="memTemplItemLeft" align="right" valign="top">constexpr <a class="el" href="structboost_1_1hana_1_1type.html">type</a>&lt; T &gt;&#160;</td><td class="memTemplItemRight" valign="bottom"><a class="el" href="structboost_1_1hana_1_1type.html#ae35139e732c4b75e91061513cf445628">type_c</a> {}</td></tr>
<tr class="memdesc:ae35139e732c4b75e91061513cf445628"><td class="mdescLeft">&#160;</td><td class="mdescRight">Creates an object representing the C++ type <code>T</code>.  <a href="#ae35139e732c4b75e91061513cf445628">More...</a><br /></td></tr>
<tr class="separator:ae35139e732c4b75e91061513cf445628"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a7d68ff2275cbb295556d83598f04e39a"><td class="memItemLeft" align="right" valign="top">constexpr auto&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="structboost_1_1hana_1_1type.html#a7d68ff2275cbb295556d83598f04e39a">decltype_</a> = see documentation</td></tr>
<tr class="memdesc:a7d68ff2275cbb295556d83598f04e39a"><td class="mdescLeft">&#160;</td><td class="mdescRight"><code>decltype</code> keyword, lifted to Hana.  <a href="#a7d68ff2275cbb295556d83598f04e39a">More...</a><br /></td></tr>
<tr class="separator:a7d68ff2275cbb295556d83598f04e39a"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a0ade557ac4240552c92bf47c7e04dfd4"><td class="memItemLeft" align="right" valign="top">constexpr auto&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="structboost_1_1hana_1_1type.html#a0ade557ac4240552c92bf47c7e04dfd4">typeid_</a> = see documentation</td></tr>
<tr class="memdesc:a0ade557ac4240552c92bf47c7e04dfd4"><td class="mdescLeft">&#160;</td><td class="mdescRight">Returns a <code><a class="el" href="structboost_1_1hana_1_1type.html" title="C++ type in value-level representation. ">hana::type</a></code> representing the type of a given object.  <a href="#a0ade557ac4240552c92bf47c7e04dfd4">More...</a><br /></td></tr>
<tr class="separator:a0ade557ac4240552c92bf47c7e04dfd4"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a66f97c1903dcb6f227b29f3e35e68a56"><td class="memTemplParams" colspan="2">template&lt;&gt; </td></tr>
<tr class="memitem:a66f97c1903dcb6f227b29f3e35e68a56"><td class="memTemplItemLeft" align="right" valign="top">constexpr auto&#160;</td><td class="memTemplItemRight" valign="bottom"><a class="el" href="structboost_1_1hana_1_1type.html#a66f97c1903dcb6f227b29f3e35e68a56">make&lt; type_tag &gt;</a> = hana::decltype_</td></tr>
<tr class="memdesc:a66f97c1903dcb6f227b29f3e35e68a56"><td class="mdescLeft">&#160;</td><td class="mdescRight">Equivalent to <code>decltype_</code>, provided for convenience.  <a href="#a66f97c1903dcb6f227b29f3e35e68a56">More...</a><br /></td></tr>
<tr class="separator:a66f97c1903dcb6f227b29f3e35e68a56"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a0c0e00c0ffe63703f3a04960d13c7b1c"><td class="memItemLeft" align="right" valign="top">constexpr auto&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="structboost_1_1hana_1_1type.html#a0c0e00c0ffe63703f3a04960d13c7b1c">make_type</a> = <a class="el" href="group__group-core.html#ga1d92480f0af1029878e773dafa3e2f60">hana::make</a>&lt;<a class="el" href="structboost_1_1hana_1_1type__tag.html">type_tag</a>&gt;</td></tr>
<tr class="memdesc:a0c0e00c0ffe63703f3a04960d13c7b1c"><td class="mdescLeft">&#160;</td><td class="mdescRight">Equivalent to <code>make&lt;<a class="el" href="structboost_1_1hana_1_1type__tag.html" title="Tag representing hana::type. ">type_tag</a>&gt;</code>, provided for convenience.  <a href="#a0c0e00c0ffe63703f3a04960d13c7b1c">More...</a><br /></td></tr>
<tr class="separator:a0c0e00c0ffe63703f3a04960d13c7b1c"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a26b702b280ca02f118affaaca9112a8c"><td class="memItemLeft" align="right" valign="top">constexpr auto&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="structboost_1_1hana_1_1type.html#a26b702b280ca02f118affaaca9112a8c">sizeof_</a></td></tr>
<tr class="memdesc:a26b702b280ca02f118affaaca9112a8c"><td class="mdescLeft">&#160;</td><td class="mdescRight"><code>sizeof</code> keyword, lifted to Hana.  <a href="#a26b702b280ca02f118affaaca9112a8c">More...</a><br /></td></tr>
<tr class="separator:a26b702b280ca02f118affaaca9112a8c"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a6fd9ac456f4b5574dcb16384dbb85736"><td class="memItemLeft" align="right" valign="top">constexpr auto&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="structboost_1_1hana_1_1type.html#a6fd9ac456f4b5574dcb16384dbb85736">alignof_</a></td></tr>
<tr class="memdesc:a6fd9ac456f4b5574dcb16384dbb85736"><td class="mdescLeft">&#160;</td><td class="mdescRight"><code>alignof</code> keyword, lifted to Hana.  <a href="#a6fd9ac456f4b5574dcb16384dbb85736">More...</a><br /></td></tr>
<tr class="separator:a6fd9ac456f4b5574dcb16384dbb85736"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a2d2e7e08e284f7e0bd1bd9c3ad0e0a2b"><td class="memItemLeft" align="right" valign="top">constexpr auto&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="structboost_1_1hana_1_1type.html#a2d2e7e08e284f7e0bd1bd9c3ad0e0a2b">is_valid</a></td></tr>
<tr class="memdesc:a2d2e7e08e284f7e0bd1bd9c3ad0e0a2b"><td class="mdescLeft">&#160;</td><td class="mdescRight">Checks whether a SFINAE-friendly expression is valid.  <a href="#a2d2e7e08e284f7e0bd1bd9c3ad0e0a2b">More...</a><br /></td></tr>
<tr class="separator:a2d2e7e08e284f7e0bd1bd9c3ad0e0a2b"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="friends"></a>
Friends</h2></td></tr>
<tr class="memitem:a27607958295e6da8a0ba602a2db468f1"><td class="memTemplParams" colspan="2"><a class="anchor" id="a27607958295e6da8a0ba602a2db468f1"></a>
template&lt;typename X , typename Y &gt; </td></tr>
<tr class="memitem:a27607958295e6da8a0ba602a2db468f1"><td class="memTemplItemLeft" align="right" valign="top">constexpr auto&#160;</td><td class="memTemplItemRight" valign="bottom"><a class="el" href="structboost_1_1hana_1_1type.html#a27607958295e6da8a0ba602a2db468f1">operator==</a> (X &amp;&amp;x, Y &amp;&amp;y)</td></tr>
<tr class="memdesc:a27607958295e6da8a0ba602a2db468f1"><td class="mdescLeft">&#160;</td><td class="mdescRight">Equivalent to <code><a class="el" href="group__group-Comparable.html#gacaf1ebea6b3ab96ac9dcb82f0e64e547" title="Returns a Logical representing whether x is equal to y.The equal function can be called in two differ...">hana::equal</a></code> <br /></td></tr>
<tr class="separator:a27607958295e6da8a0ba602a2db468f1"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a0cae3af55edb3eb05bfa184bda633f7d"><td class="memTemplParams" colspan="2"><a class="anchor" id="a0cae3af55edb3eb05bfa184bda633f7d"></a>
template&lt;typename X , typename Y &gt; </td></tr>
<tr class="memitem:a0cae3af55edb3eb05bfa184bda633f7d"><td class="memTemplItemLeft" align="right" valign="top">constexpr auto&#160;</td><td class="memTemplItemRight" valign="bottom"><a class="el" href="structboost_1_1hana_1_1type.html#a0cae3af55edb3eb05bfa184bda633f7d">operator!=</a> (X &amp;&amp;x, Y &amp;&amp;y)</td></tr>
<tr class="memdesc:a0cae3af55edb3eb05bfa184bda633f7d"><td class="mdescLeft">&#160;</td><td class="mdescRight">Equivalent to <code><a class="el" href="group__group-Comparable.html#gae33be2e0d5e04f19082f4b7740dfc9cd" title="Returns a Logical representing whether x is not equal to y.The not_equal function can be called in tw...">hana::not_equal</a></code> <br /></td></tr>
<tr class="separator:a0cae3af55edb3eb05bfa184bda633f7d"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pub-methods"></a>
Public Member Functions</h2></td></tr>
<tr class="memitem:a2c3bef01b2e0342264c62a67cc471592"><td class="memItemLeft" align="right" valign="top"><a class="anchor" id="a2c3bef01b2e0342264c62a67cc471592"></a>
constexpr auto&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="structboost_1_1hana_1_1type.html#a2c3bef01b2e0342264c62a67cc471592">operator+</a> () const </td></tr>
<tr class="memdesc:a2c3bef01b2e0342264c62a67cc471592"><td class="mdescLeft">&#160;</td><td class="mdescRight">Returns rvalue of self. See <a class="el" href="structboost_1_1hana_1_1type.html#type_lvalues_and_rvalues">description</a>. <br /></td></tr>
<tr class="separator:a2c3bef01b2e0342264c62a67cc471592"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<h2 class="groupheader">Associated functions</h2>
<a class="anchor" id="ae35139e732c4b75e91061513cf445628"></a>
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename T &gt; </div>
<div class="memtemplate">
template&lt;typename T &gt; </div>
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">constexpr <a class="el" href="structboost_1_1hana_1_1type.html">type</a>&lt;T&gt; type_c {}</td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">related</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Creates an object representing the C++ type <code>T</code>. </p>

</div>
</div>
<a class="anchor" id="a7d68ff2275cbb295556d83598f04e39a"></a>
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename T &gt; </div>
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">constexpr auto decltype_ = see documentation</td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">related</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p><code>decltype</code> keyword, lifted to Hana. </p>
<dl class="deprecated"><dt><b><a class="el" href="deprecated.html#_deprecated000001">Deprecated:</a></b></dt><dd>The semantics of <code>decltype_</code> can be confusing, and <code>hana::typeid_</code> should be preferred instead. <code>decltype_</code> may be removed in the next major version of the library.</dd></dl>
<p><code>decltype_</code> is somewhat equivalent to <code>decltype</code> in that it returns the type of an object, except it returns it as a <code><a class="el" href="structboost_1_1hana_1_1type.html" title="C++ type in value-level representation. ">hana::type</a></code> which is a first-class citizen of Hana instead of a raw C++ type. Specifically, given an object <code>x</code>, <code>decltype_</code> satisfies </p><div class="fragment"><div class="line"><a class="code" href="structboost_1_1hana_1_1type.html#a7d68ff2275cbb295556d83598f04e39a">decltype_</a>(x) == type_c&lt;decltype(x) with references stripped&gt;</div></div><!-- fragment --><p>As you can see, <code>decltype_</code> will strip any reference from the object's actual type. The reason for doing so is explained below. However, any <code>cv</code>-qualifiers will be retained. Also, when given a <code><a class="el" href="structboost_1_1hana_1_1type.html" title="C++ type in value-level representation. ">hana::type</a></code>, <code>decltype_</code> is just the identity function. Hence, for any C++ type <code>T</code>, </p><div class="fragment"><div class="line"><a class="code" href="structboost_1_1hana_1_1type.html#a7d68ff2275cbb295556d83598f04e39a">decltype_</a>(type_c&lt;T&gt;) == type_c&lt;T&gt;</div></div><!-- fragment --><p>In conjunction with the way <code>metafunction</code> &amp; al. are specified, this behavior makes it easier to interact with both types and values at the same time. However, it does make it impossible to create a <code>type</code> containing another <code>type</code> with <code>decltype_</code>. In other words, it is not possible to create a <code>type_c&lt;decltype(type_c&lt;T&gt;)&gt;</code> with this utility, because <code>decltype_(type_c&lt;T&gt;)</code> would be just <code>type_c&lt;T&gt;</code> instead of <code>type_c&lt;decltype(type_c&lt;T&gt;)&gt;</code>. This use case is assumed to be rare and a hand-coded function can be used if this is needed.</p>
<h3>Rationale for stripping the references</h3>
<p>The rules for template argument deduction are such that a perfect solution that always matches <code>decltype</code> is impossible. Hence, we have to settle on a solution that's good and and consistent enough for our needs. One case where matching <code>decltype</code>'s behavior is impossible is when the argument is a plain, unparenthesized variable or function parameter. In that case, <code>decltype_</code>'s argument will be deduced as a reference to that variable, but <code>decltype</code> would have given us the actual type of that variable, without references. Also, given the current definition of <code>metafunction</code> &amp; al., it would be mostly useless if <code>decltype_</code> could return a reference, because it is unlikely that <code>F</code> expects a reference in its simplest use case: </p><div class="fragment"><div class="line"><span class="keywordtype">int</span> i = 0;</div><div class="line"><span class="keyword">auto</span> result = metafunction&lt;F&gt;(i);</div></div><!-- fragment --><p>Hence, always discarding references seems to be the least painful solution.</p>
<h2>Example </h2>
<div class="fragment"><div class="line"><span class="comment">// Copyright Louis Dionne 2013-2016</span></div><div class="line"><span class="comment">// Distributed under the Boost Software License, Version 1.0.</span></div><div class="line"><span class="comment">// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)</span></div><div class="line"></div><div class="line"><span class="preprocessor">#include &lt;<a class="code" href="assert_8hpp.html">boost/hana/assert.hpp</a>&gt;</span></div><div class="line"><span class="preprocessor">#include &lt;<a class="code" href="equal_8hpp.html">boost/hana/equal.hpp</a>&gt;</span></div><div class="line"><span class="preprocessor">#include &lt;<a class="code" href="type_8hpp.html">boost/hana/type.hpp</a>&gt;</span></div><div class="line"><span class="keyword">namespace </span>hana = <a class="code" href="namespaceboost_1_1hana.html">boost::hana</a>;</div><div class="line"></div><div class="line"></div><div class="line"><span class="keyword">struct </span>X { };</div><div class="line"><a class="code" href="group__group-assertions.html#ga4bf9e0c46c44e21fbe5c5fbb3ace8356">BOOST_HANA_CONSTANT_CHECK</a>(hana::decltype_(X{}) == hana::type_c&lt;X&gt;);</div><div class="line"><a class="code" href="group__group-assertions.html#ga4bf9e0c46c44e21fbe5c5fbb3ace8356">BOOST_HANA_CONSTANT_CHECK</a>(hana::decltype_(hana::type_c&lt;X&gt;) == hana::type_c&lt;X&gt;);</div><div class="line"></div><div class="line"><a class="code" href="group__group-assertions.html#ga4bf9e0c46c44e21fbe5c5fbb3ace8356">BOOST_HANA_CONSTANT_CHECK</a>(hana::decltype_(1) == hana::type_c&lt;int&gt;);</div><div class="line"></div><div class="line"><span class="keyword">static</span> <span class="keywordtype">int</span> <span class="keyword">const</span>&amp; i = 1;</div><div class="line"><a class="code" href="group__group-assertions.html#ga4bf9e0c46c44e21fbe5c5fbb3ace8356">BOOST_HANA_CONSTANT_CHECK</a>(hana::decltype_(i) == hana::type_c&lt;int const&gt;);</div><div class="line"></div><div class="line"><span class="keywordtype">int</span> main() { }</div></div><!-- fragment -->
</div>
</div>
<a class="anchor" id="a0ade557ac4240552c92bf47c7e04dfd4"></a>
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename T &gt; </div>
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">constexpr auto typeid_ = see documentation</td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">related</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Returns a <code><a class="el" href="structboost_1_1hana_1_1type.html" title="C++ type in value-level representation. ">hana::type</a></code> representing the type of a given object. </p>
<p><code>hana::typeid_</code> is somewhat similar to <code>typeid</code> in that it returns something that represents the type of an object. However, what <code>typeid</code> returns represent the <em>runtime</em> type of the object, while <code>hana::typeid_</code> returns the <em>static</em> type of the object. Specifically, given an object <code>x</code>, <code>typeid_</code> satisfies </p><div class="fragment"><div class="line"><a class="code" href="structboost_1_1hana_1_1type.html#a0ade557ac4240552c92bf47c7e04dfd4">typeid_</a>(x) == <a class="code" href="structboost_1_1hana_1_1type.html#ae35139e732c4b75e91061513cf445628">type_c</a>&lt;decltype(x) with ref and cv-qualifiers stripped&gt;</div></div><!-- fragment --><p>As you can see, <code>typeid_</code> strips any reference and cv-qualifier from the object's actual type. The reason for doing so is that it faithfully models how the language's <code>typeid</code> behaves with respect to reference and cv-qualifiers, and it also turns out to be the desirable behavior most of the time. Also, when given a <code><a class="el" href="structboost_1_1hana_1_1type.html" title="C++ type in value-level representation. ">hana::type</a></code>, <code>typeid_</code> is just the identity function. Hence, for any C++ type <code>T</code>, </p><div class="fragment"><div class="line"><a class="code" href="structboost_1_1hana_1_1type.html#a0ade557ac4240552c92bf47c7e04dfd4">typeid_</a>(type_c&lt;T&gt;) == type_c&lt;T&gt;</div></div><!-- fragment --><p>In conjunction with the way <code>metafunction</code> &amp; al. are specified, this behavior makes it easier to interact with both types and values at the same time. However, it does make it impossible to create a <code>type</code> containing another <code>type</code> using <code>typeid_</code>. This use case is assumed to be rare and a hand-coded function can be used if this is needed.</p>
<h2>Example </h2>
<div class="fragment"><div class="line"><span class="comment">// Copyright Louis Dionne 2013-2016</span></div><div class="line"><span class="comment">// Distributed under the Boost Software License, Version 1.0.</span></div><div class="line"><span class="comment">// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)</span></div><div class="line"></div><div class="line"><span class="preprocessor">#include &lt;<a class="code" href="assert_8hpp.html">boost/hana/assert.hpp</a>&gt;</span></div><div class="line"><span class="preprocessor">#include &lt;<a class="code" href="equal_8hpp.html">boost/hana/equal.hpp</a>&gt;</span></div><div class="line"><span class="preprocessor">#include &lt;<a class="code" href="remove__if_8hpp.html">boost/hana/remove_if.hpp</a>&gt;</span></div><div class="line"><span class="preprocessor">#include &lt;<a class="code" href="tuple_8hpp.html">boost/hana/tuple.hpp</a>&gt;</span></div><div class="line"><span class="preprocessor">#include &lt;<a class="code" href="type_8hpp.html">boost/hana/type.hpp</a>&gt;</span></div><div class="line"></div><div class="line"><span class="preprocessor">#include &lt;string&gt;</span></div><div class="line"><span class="keyword">namespace </span>hana = <a class="code" href="namespaceboost_1_1hana.html">boost::hana</a>;</div><div class="line"></div><div class="line"></div><div class="line"><span class="keyword">struct </span>Cat { std::string name; };</div><div class="line"><span class="keyword">struct </span>Dog { std::string name; };</div><div class="line"><span class="keyword">struct </span>Fish { std::string name; };</div><div class="line"></div><div class="line"><span class="keywordtype">bool</span> <a class="code" href="structboost_1_1hana_1_1type.html#a27607958295e6da8a0ba602a2db468f1">operator==</a>(Cat <span class="keyword">const</span>&amp; a, Cat <span class="keyword">const</span>&amp; b) { <span class="keywordflow">return</span> a.name == b.name; }</div><div class="line"><span class="keywordtype">bool</span> <a class="code" href="structboost_1_1hana_1_1type.html#a0cae3af55edb3eb05bfa184bda633f7d">operator!=</a>(Cat <span class="keyword">const</span>&amp; a, Cat <span class="keyword">const</span>&amp; b) { <span class="keywordflow">return</span> a.name != b.name; }</div><div class="line"><span class="keywordtype">bool</span> <a class="code" href="structboost_1_1hana_1_1type.html#a27607958295e6da8a0ba602a2db468f1">operator==</a>(Dog <span class="keyword">const</span>&amp; a, Dog <span class="keyword">const</span>&amp; b) { <span class="keywordflow">return</span> a.name == b.name; }</div><div class="line"><span class="keywordtype">bool</span> <a class="code" href="structboost_1_1hana_1_1type.html#a0cae3af55edb3eb05bfa184bda633f7d">operator!=</a>(Dog <span class="keyword">const</span>&amp; a, Dog <span class="keyword">const</span>&amp; b) { <span class="keywordflow">return</span> a.name != b.name; }</div><div class="line"><span class="keywordtype">bool</span> <a class="code" href="structboost_1_1hana_1_1type.html#a27607958295e6da8a0ba602a2db468f1">operator==</a>(Fish <span class="keyword">const</span>&amp; a, Fish <span class="keyword">const</span>&amp; b) { <span class="keywordflow">return</span> a.name == b.name; }</div><div class="line"><span class="keywordtype">bool</span> <a class="code" href="structboost_1_1hana_1_1type.html#a0cae3af55edb3eb05bfa184bda633f7d">operator!=</a>(Fish <span class="keyword">const</span>&amp; a, Fish <span class="keyword">const</span>&amp; b) { <span class="keywordflow">return</span> a.name != b.name; }</div><div class="line"></div><div class="line"><span class="keywordtype">int</span> main() {</div><div class="line">    hana::tuple&lt;Cat, Fish, Dog, Fish&gt; animals{</div><div class="line">        Cat{<span class="stringliteral">&quot;Garfield&quot;</span>}, Fish{<span class="stringliteral">&quot;Jaws&quot;</span>}, Dog{<span class="stringliteral">&quot;Beethoven&quot;</span>}, Fish{<span class="stringliteral">&quot;Nemo&quot;</span>}</div><div class="line">    };</div><div class="line"></div><div class="line">    <span class="keyword">auto</span> mammals = <a class="code" href="group__group-MonadPlus.html#ga9700169a45664d50377c1be9d58accd3">hana::remove_if</a>(animals, [](<span class="keyword">auto</span> <span class="keyword">const</span>&amp; a) {</div><div class="line">        <span class="keywordflow">return</span> hana::typeid_(a) == hana::type&lt;Fish&gt;{};</div><div class="line">    });</div><div class="line"></div><div class="line">    <a class="code" href="group__group-assertions.html#ga29b2b21ffa5513e5b706c50ffee980af">BOOST_HANA_RUNTIME_CHECK</a>(mammals == hana::make_tuple(Cat{<span class="stringliteral">&quot;Garfield&quot;</span>}, Dog{<span class="stringliteral">&quot;Beethoven&quot;</span>}));</div><div class="line">}</div></div><!-- fragment -->
</div>
</div>
<a class="anchor" id="a66f97c1903dcb6f227b29f3e35e68a56"></a>
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename T &gt; </div>
<div class="memtemplate">
template&lt;&gt; </div>
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">constexpr auto <a class="el" href="group__group-core.html#ga1d92480f0af1029878e773dafa3e2f60">make</a>&lt; <a class="el" href="structboost_1_1hana_1_1type__tag.html">type_tag</a> &gt; = hana::decltype_</td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">related</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Equivalent to <code>decltype_</code>, provided for convenience. </p>
<h2>Example </h2>
<div class="fragment"><div class="line"><span class="comment">// Copyright Louis Dionne 2013-2016</span></div><div class="line"><span class="comment">// Distributed under the Boost Software License, Version 1.0.</span></div><div class="line"><span class="comment">// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)</span></div><div class="line"></div><div class="line"><span class="preprocessor">#include &lt;<a class="code" href="assert_8hpp.html">boost/hana/assert.hpp</a>&gt;</span></div><div class="line"><span class="preprocessor">#include &lt;<a class="code" href="core_2make_8hpp.html">boost/hana/core/make.hpp</a>&gt;</span></div><div class="line"><span class="preprocessor">#include &lt;<a class="code" href="equal_8hpp.html">boost/hana/equal.hpp</a>&gt;</span></div><div class="line"><span class="preprocessor">#include &lt;<a class="code" href="type_8hpp.html">boost/hana/type.hpp</a>&gt;</span></div><div class="line"><span class="keyword">namespace </span>hana = <a class="code" href="namespaceboost_1_1hana.html">boost::hana</a>;</div><div class="line"></div><div class="line"></div><div class="line"><span class="keyword">struct </span>X { };</div><div class="line"><a class="code" href="group__group-assertions.html#ga4bf9e0c46c44e21fbe5c5fbb3ace8356">BOOST_HANA_CONSTANT_CHECK</a>(hana::make&lt;hana::type_tag&gt;(X{}) == hana::type_c&lt;X&gt;);</div><div class="line"><a class="code" href="group__group-assertions.html#ga4bf9e0c46c44e21fbe5c5fbb3ace8356">BOOST_HANA_CONSTANT_CHECK</a>(hana::make&lt;hana::type_tag&gt;(hana::type_c&lt;X&gt;) == hana::type_c&lt;X&gt;);</div><div class="line"></div><div class="line"><a class="code" href="group__group-assertions.html#ga4bf9e0c46c44e21fbe5c5fbb3ace8356">BOOST_HANA_CONSTANT_CHECK</a>(hana::make_type(X{}) == hana::type_c&lt;X&gt;);</div><div class="line"><a class="code" href="group__group-assertions.html#ga4bf9e0c46c44e21fbe5c5fbb3ace8356">BOOST_HANA_CONSTANT_CHECK</a>(hana::make_type(hana::type_c&lt;X&gt;) == hana::type_c&lt;X&gt;);</div><div class="line"></div><div class="line"><span class="keywordtype">int</span> main() { }</div></div><!-- fragment -->
</div>
</div>
<a class="anchor" id="a0c0e00c0ffe63703f3a04960d13c7b1c"></a>
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename T &gt; </div>
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">constexpr auto make_type = <a class="el" href="group__group-core.html#ga1d92480f0af1029878e773dafa3e2f60">hana::make</a>&lt;<a class="el" href="structboost_1_1hana_1_1type__tag.html">type_tag</a>&gt;</td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">related</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Equivalent to <code>make&lt;<a class="el" href="structboost_1_1hana_1_1type__tag.html" title="Tag representing hana::type. ">type_tag</a>&gt;</code>, provided for convenience. </p>
<h2>Example </h2>
<div class="fragment"><div class="line"><span class="comment">// Copyright Louis Dionne 2013-2016</span></div><div class="line"><span class="comment">// Distributed under the Boost Software License, Version 1.0.</span></div><div class="line"><span class="comment">// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)</span></div><div class="line"></div><div class="line"><span class="preprocessor">#include &lt;<a class="code" href="assert_8hpp.html">boost/hana/assert.hpp</a>&gt;</span></div><div class="line"><span class="preprocessor">#include &lt;<a class="code" href="core_2make_8hpp.html">boost/hana/core/make.hpp</a>&gt;</span></div><div class="line"><span class="preprocessor">#include &lt;<a class="code" href="equal_8hpp.html">boost/hana/equal.hpp</a>&gt;</span></div><div class="line"><span class="preprocessor">#include &lt;<a class="code" href="type_8hpp.html">boost/hana/type.hpp</a>&gt;</span></div><div class="line"><span class="keyword">namespace </span>hana = <a class="code" href="namespaceboost_1_1hana.html">boost::hana</a>;</div><div class="line"></div><div class="line"></div><div class="line"><span class="keyword">struct </span>X { };</div><div class="line"><a class="code" href="group__group-assertions.html#ga4bf9e0c46c44e21fbe5c5fbb3ace8356">BOOST_HANA_CONSTANT_CHECK</a>(hana::make&lt;hana::type_tag&gt;(X{}) == hana::type_c&lt;X&gt;);</div><div class="line"><a class="code" href="group__group-assertions.html#ga4bf9e0c46c44e21fbe5c5fbb3ace8356">BOOST_HANA_CONSTANT_CHECK</a>(hana::make&lt;hana::type_tag&gt;(hana::type_c&lt;X&gt;) == hana::type_c&lt;X&gt;);</div><div class="line"></div><div class="line"><a class="code" href="group__group-assertions.html#ga4bf9e0c46c44e21fbe5c5fbb3ace8356">BOOST_HANA_CONSTANT_CHECK</a>(hana::make_type(X{}) == hana::type_c&lt;X&gt;);</div><div class="line"><a class="code" href="group__group-assertions.html#ga4bf9e0c46c44e21fbe5c5fbb3ace8356">BOOST_HANA_CONSTANT_CHECK</a>(hana::make_type(hana::type_c&lt;X&gt;) == hana::type_c&lt;X&gt;);</div><div class="line"></div><div class="line"><span class="keywordtype">int</span> main() { }</div></div><!-- fragment -->
</div>
</div>
<a class="anchor" id="a26b702b280ca02f118affaaca9112a8c"></a>
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename T &gt; </div>
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">constexpr auto sizeof_</td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">related</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">
<b>Initial value:</b><div class="fragment"><div class="line">= [](<span class="keyword">auto</span>&amp;&amp; x) {</div><div class="line">        <span class="keyword">using</span> T = <span class="keyword">typename</span> decltype(hana::decltype_(x))::type;</div><div class="line">        <span class="keywordflow">return</span> hana::size_c&lt;sizeof(T)&gt;;</div><div class="line">    }</div></div><!-- fragment -->
<p><code>sizeof</code> keyword, lifted to Hana. </p>
<p><code>sizeof_</code> is somewhat equivalent to <code>sizeof</code> in that it returns the size of an expression or type, but it takes an arbitrary expression or a <code><a class="el" href="structboost_1_1hana_1_1type.html" title="C++ type in value-level representation. ">hana::type</a></code> and returns its size as an <code><a class="el" href="structboost_1_1hana_1_1integral__constant.html" title="Compile-time value of an integral type. ">integral_constant</a></code>. Specifically, given an expression <code>expr</code>, <code>sizeof_</code> satisfies </p><div class="fragment"><div class="line"><a class="code" href="structboost_1_1hana_1_1type.html#a26b702b280ca02f118affaaca9112a8c">sizeof_</a>(expr) == size_t&lt;sizeof(decltype(expr) with references stripped)&gt;</div></div><!-- fragment --><p>However, given a <code>type</code>, <code>sizeof_</code> will simply fetch the size of the C++ type represented by that object. In other words, </p><div class="fragment"><div class="line"><a class="code" href="structboost_1_1hana_1_1type.html#a26b702b280ca02f118affaaca9112a8c">sizeof_</a>(type_c&lt;T&gt;) == size_t&lt;sizeof(T)&gt;</div></div><!-- fragment --><p>The behavior of <code>sizeof_</code> is consistent with that of <code>decltype_</code>. In particular, see <code>decltype_</code>'s documentation to understand why references are always stripped by <code>sizeof_</code>.</p>
<h2>Example </h2>
<div class="fragment"><div class="line"><span class="comment">// Copyright Louis Dionne 2013-2016</span></div><div class="line"><span class="comment">// Distributed under the Boost Software License, Version 1.0.</span></div><div class="line"><span class="comment">// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)</span></div><div class="line"></div><div class="line"><span class="preprocessor">#include &lt;<a class="code" href="equal_8hpp.html">boost/hana/equal.hpp</a>&gt;</span></div><div class="line"><span class="preprocessor">#include &lt;<a class="code" href="type_8hpp.html">boost/hana/type.hpp</a>&gt;</span></div><div class="line"><span class="keyword">namespace </span>hana = <a class="code" href="namespaceboost_1_1hana.html">boost::hana</a>;</div><div class="line"></div><div class="line"></div><div class="line"><span class="keyword">struct </span>X { };</div><div class="line">static_assert(hana::sizeof_(hana::type_c&lt;X&gt;) == <span class="keyword">sizeof</span>(X), <span class="stringliteral">&quot;&quot;</span>);</div><div class="line"></div><div class="line">static_assert(hana::sizeof_(1) == <span class="keyword">sizeof</span>(1), <span class="stringliteral">&quot;&quot;</span>);</div><div class="line">static_assert(hana::sizeof_(hana::type_c&lt;int&gt;) == <span class="keyword">sizeof</span>(<span class="keywordtype">int</span>), <span class="stringliteral">&quot;&quot;</span>);</div><div class="line"></div><div class="line"><span class="keywordtype">int</span> main() {}</div></div><!-- fragment -->
</div>
</div>
<a class="anchor" id="a6fd9ac456f4b5574dcb16384dbb85736"></a>
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename T &gt; </div>
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">constexpr auto alignof_</td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">related</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">
<b>Initial value:</b><div class="fragment"><div class="line">= [](<span class="keyword">auto</span>&amp;&amp; x) {</div><div class="line">        <span class="keyword">using</span> T = <span class="keyword">typename</span> decltype(hana::decltype_(x))::type;</div><div class="line">        <span class="keywordflow">return</span> hana::size_c&lt;alignof(T)&gt;;</div><div class="line">    }</div></div><!-- fragment -->
<p><code>alignof</code> keyword, lifted to Hana. </p>
<p><code>alignof_</code> is somewhat equivalent to <code>alignof</code> in that it returns the alignment required by any instance of a type, but it takes a <code>type</code> and returns its alignment as an <code><a class="el" href="structboost_1_1hana_1_1integral__constant.html" title="Compile-time value of an integral type. ">integral_constant</a></code>. Like <code>sizeof</code> which works for expressions and type-ids, <code>alignof_</code> can also be called on an arbitrary expression. Specifically, given an expression <code>expr</code> and a C++ type <code>T</code>, <code>alignof_</code> satisfies </p><div class="fragment"><div class="line"><a class="code" href="structboost_1_1hana_1_1type.html#a6fd9ac456f4b5574dcb16384dbb85736">alignof_</a>(expr) == size_t&lt;alignof(decltype(expr) with references stripped)&gt;</div><div class="line"><a class="code" href="structboost_1_1hana_1_1type.html#a6fd9ac456f4b5574dcb16384dbb85736">alignof_</a>(type_c&lt;T&gt;) == size_t&lt;alignof(T)&gt;</div></div><!-- fragment --><p>The behavior of <code>alignof_</code> is consistent with that of <code>decltype_</code>. In particular, see <code>decltype_</code>'s documentation to understand why references are always stripped by <code>alignof_</code>.</p>
<h2>Example </h2>
<div class="fragment"><div class="line"><span class="comment">// Copyright Louis Dionne 2013-2016</span></div><div class="line"><span class="comment">// Distributed under the Boost Software License, Version 1.0.</span></div><div class="line"><span class="comment">// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)</span></div><div class="line"></div><div class="line"><span class="preprocessor">#include &lt;<a class="code" href="equal_8hpp.html">boost/hana/equal.hpp</a>&gt;</span></div><div class="line"><span class="preprocessor">#include &lt;<a class="code" href="type_8hpp.html">boost/hana/type.hpp</a>&gt;</span></div><div class="line"><span class="keyword">namespace </span>hana = <a class="code" href="namespaceboost_1_1hana.html">boost::hana</a>;</div><div class="line"></div><div class="line"></div><div class="line"><span class="keyword">struct </span>X { };</div><div class="line">static_assert(hana::alignof_(hana::type_c&lt;X&gt;) == <span class="keyword">alignof</span>(X), <span class="stringliteral">&quot;&quot;</span>);</div><div class="line"></div><div class="line">static_assert(hana::alignof_(1) == <span class="keyword">alignof</span>(decltype(1)), <span class="stringliteral">&quot;&quot;</span>);</div><div class="line">static_assert(hana::alignof_(hana::type_c&lt;int&gt;) == <span class="keyword">alignof</span>(<span class="keywordtype">int</span>), <span class="stringliteral">&quot;&quot;</span>);</div><div class="line"></div><div class="line"><span class="keywordtype">int</span> main() { }</div></div><!-- fragment -->
</div>
</div>
<a class="anchor" id="a2d2e7e08e284f7e0bd1bd9c3ad0e0a2b"></a>
<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename T &gt; </div>
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">constexpr auto is_valid</td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">related</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">
<b>Initial value:</b><div class="fragment"><div class="line">= [](<span class="keyword">auto</span>&amp;&amp; f) {</div><div class="line">        <span class="keywordflow">return</span> [](<span class="keyword">auto</span>&amp;&amp; ...args) {</div><div class="line">            <span class="keywordflow">return</span> whether f(args...) is a valid expression;</div><div class="line">        };</div><div class="line">    }</div></div><!-- fragment -->
<p>Checks whether a SFINAE-friendly expression is valid. </p>
<p>Given a SFINAE-friendly function, <code>is_valid</code> returns whether the function call is valid with the given arguments. Specifically, given a function <code>f</code> and arguments <code>args...</code>, </p><div class="fragment"><div class="line"><a class="code" href="structboost_1_1hana_1_1type.html#a2d2e7e08e284f7e0bd1bd9c3ad0e0a2b">is_valid</a>(f, args...) == whether f(args...) is valid</div></div><!-- fragment --><p>The result is returned as a compile-time <code>Logical</code>. Furthermore, <code>is_valid</code> can be used in curried form as follows: </p><div class="fragment"><div class="line"><a class="code" href="structboost_1_1hana_1_1type.html#a2d2e7e08e284f7e0bd1bd9c3ad0e0a2b">is_valid</a>(f)(args...)</div></div><!-- fragment --><p>This syntax makes it easy to create functions that check the validity of a generic expression on any given argument(s).</p>
<dl class="section warning"><dt>Warning</dt><dd>To check whether calling a nullary function <code>f</code> is valid, one should use the <code>is_valid(f)()</code> syntax. Indeed, <code>is_valid(f /* no args */)</code> will be interpreted as the currying of <code>is_valid</code> to <code>f</code> rather than the application of <code>is_valid</code> to <code>f</code> and no arguments.</dd></dl>
<h2>Example </h2>
<div class="fragment"><div class="line"><span class="comment">// Copyright Louis Dionne 2013-2016</span></div><div class="line"><span class="comment">// Distributed under the Boost Software License, Version 1.0.</span></div><div class="line"><span class="comment">// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)</span></div><div class="line"></div><div class="line"><span class="preprocessor">#include &lt;<a class="code" href="assert_8hpp.html">boost/hana/assert.hpp</a>&gt;</span></div><div class="line"><span class="preprocessor">#include &lt;<a class="code" href="not_8hpp.html">boost/hana/not.hpp</a>&gt;</span></div><div class="line"><span class="preprocessor">#include &lt;<a class="code" href="type_8hpp.html">boost/hana/type.hpp</a>&gt;</span></div><div class="line"></div><div class="line"><span class="preprocessor">#include &lt;string&gt;</span></div><div class="line"><span class="preprocessor">#include &lt;vector&gt;</span></div><div class="line"><span class="keyword">namespace </span>hana = <a class="code" href="namespaceboost_1_1hana.html">boost::hana</a>;</div><div class="line"></div><div class="line"></div><div class="line"><span class="keywordtype">int</span> main() {</div><div class="line">    <span class="comment">// Checking for a member</span></div><div class="line">    <span class="keyword">struct </span>Person { std::string name; };</div><div class="line">    <span class="keyword">auto</span> has_name = hana::is_valid([](<span class="keyword">auto</span>&amp;&amp; p) -&gt; decltype((<span class="keywordtype">void</span>)p.name) { });</div><div class="line"></div><div class="line">    Person joe{<span class="stringliteral">&quot;Joe&quot;</span>};</div><div class="line">    static_assert(has_name(joe), <span class="stringliteral">&quot;&quot;</span>);</div><div class="line">    static_assert(!has_name(1), <span class="stringliteral">&quot;&quot;</span>);</div><div class="line"></div><div class="line"></div><div class="line">    <span class="comment">// Checking for a nested type</span></div><div class="line">    <span class="keyword">auto</span> has_value_type = hana::is_valid([](<span class="keyword">auto</span> t) -&gt; hana::type&lt;</div><div class="line">        <span class="keyword">typename</span> decltype(t)::type::value_type</div><div class="line">    &gt; { });</div><div class="line"></div><div class="line">    static_assert(has_value_type(hana::type_c&lt;std::vector&lt;int&gt;&gt;), <span class="stringliteral">&quot;&quot;</span>);</div><div class="line">    static_assert(!has_value_type(hana::type_c&lt;Person&gt;), <span class="stringliteral">&quot;&quot;</span>);</div><div class="line">}</div></div><!-- fragment -->
</div>
</div>
</div><!-- contents -->
</div><!-- doc-content -->
<!--
Copyright Louis Dionne 2013-2016
Distributed under the Boost Software License, Version 1.0.
(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
-->
<!-- boost-no-inspect -->
<!-- HTML footer for doxygen 1.8.9.1-->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  <ul>
    <li class="navelem"><a class="el" href="namespaceboost.html">boost</a></li><li class="navelem"><a class="el" href="namespaceboost_1_1hana.html">hana</a></li><li class="navelem"><a class="el" href="structboost_1_1hana_1_1type.html">type</a></li>
  </ul>
</div>
</body>
</html>
